import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式文件
import './assets/css/global.css'
// 导入字体图标样式库
import './assets/fonts/iconfont.css'
import TreeTable from 'vue-table-with-tree-grid'
// 配置请求根路径
import axios from 'axios'
// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// require styles 样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor)
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 配置请求拦截器
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 必须在最后return config
  return config
})
// 以后可以直接用 this.$http 发起axios请求
Vue.prototype.$http = axios

Vue.config.productionTip = false
Vue.filter('dateFormat', function (dateStr) {
  const timeStr = new Date(dateStr)
  const y = timeStr.getFullYear()
  const m = (timeStr.getMonth() + 1 + '').padStart(2, '0')
  const d = (timeStr.getDate() + '').padStart(2, '0')

  const hh = (timeStr.getHours() + '').padStart(2, '0')
  const mm = (timeStr.getMinutes() + '').padStart(2, '0')
  const ss = (timeStr.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.component('tree-table', TreeTable)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
